package com.project.service.impl;

import cn.hutool.crypto.digest.BCrypt;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.project.entity.Users;

import com.project.mapper.UserMapper;
import com.project.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper,Users> implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public Users login(Users user) {
        Users userInDB = userMapper.selectById(user.getUserId());
        if (userInDB != null && BCrypt.checkpw(user.getPassword(), userInDB.getPassword())) {
            return userInDB;
        }
        return userInDB;
    }

    @Override
    public Long getId(Integer userId) {

      return  userMapper.getUserType(userId);
    }
}